using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Resources;
using System.Globalization;

namespace LPV_POS.mh_pos.mh_khac
{
    public partial class mh_select_khachhang : DevExpress.XtraEditors.XtraForm
    {
        CultureInfo culture;
        public string m_makhachhang = "";
        public string m_tenkhachhang = "";
        #region "Muti language"

        private void SetLanguage_banhang(string cultureName)
        {
            try
            {
                culture = CultureInfo.CreateSpecificCulture(cultureName);
                ResourceManager rm = new ResourceManager("LPV_POS.Muti_language.MyResource", typeof(mh_banhang6_PhuThu).Assembly);
                label2.Text = rm.GetString("nhomkhachhang", culture);
                label4.Text = rm.GetString("khachhang", culture);
                label1.Text = rm.GetString("dienthoai", culture);
                bton_tim.Text = rm.GetString("tim", culture);
                bton_chon.Text = rm.GetString("chon", culture);
                bton_thoat.Text = rm.GetString("thoat", culture);
                this.col_thekhachhang.Caption= rm.GetString("thekhachhang", culture);
                this.col_tenkhachhang.Caption= rm.GetString("khachhang", culture);
                this.col_sodienthoai.Caption = rm.GetString("dienthoai", culture);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Note");
            }

        }

        #endregion

        public mh_select_khachhang()
        {
            InitializeComponent();
            //CultureInfo culture;
            new thuvien().f_showdataoncombox(com_khachhang,
                                                                    new thuvien().SP_SelectDataTable("sp_chonkhachhang", new string[] {"@flag","@choose" }, new object[] {1,1 }),
                                                                    "OBJID", "OBJNAME");

        }

        private void mh_select_khachhang_Load(object sender, EventArgs e)
        {
            cpublic ocpublic = new cpublic();
            string str_lang = ocpublic.Registry_Get("mh_main_lang");
            if (str_lang == "")
                str_lang = "vi-VN";
            SetLanguage_banhang(str_lang);
            luoi_khachhang.DataSource = new thuvien().SP_SelectDataTable("sp_chonkhachhang", new string[] { "@flag", "@choose" }, new object[] { 1, 2 });
        }

        private void bton_tim_Click(object sender, EventArgs e)
        {
            luoi_khachhang.DataSource = null;
            luoi_khachhang.DataSource = new thuvien().SP_SelectDataTable("sp_chonkhachhang",
                                                                                    new string[] { "@flag", "@choose", "@nhomkh", "@tenkhachhang", "@sodienthoai" }, 
                                                                                    new object[] { 1, 3, com_khachhang._GetselectedID(), txt_tenkhachhang.Text , txt_sodienthoai.Text });
        }

        private void bton_thoat_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void bton_chon_Click(object sender, EventArgs e)
        {
            if (grid_khachhang.RowCount > 0)
            {
                m_makhachhang = grid_khachhang.GetRowCellDisplayText(grid_khachhang.FocusedRowHandle, col_makhachhang) + "";
                m_tenkhachhang = grid_khachhang.GetRowCellDisplayText(grid_khachhang.FocusedRowHandle, col_tenkhachhang) + "";
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
               
        }

        private void check_khachhang_CheckedChanged(object sender, EventArgs e)
        {
            if (check_khachhang.Checked == false)
            {
                com_khachhang.Text = "";
                com_khachhang.Enabled = false;
                com_khachhang.BackColor = System.Drawing.Color.White;
            }
            else
                com_khachhang.Enabled = true;
        }

        private void bton_sodienthoai_Click(object sender, EventArgs e)
        {

        }
    }
}